# Contributor: Grigory Kirillov <txgk@bk.ru>
# Maintainer:
pkgname=litehtml
pkgver=0.8
pkgrel=2
pkgdesc="Fast and lightweight HTML/CSS rendering engine"
url="http://www.litehtml.com"
arch="all"
license="BSD-3-Clause"
makedepends="cmake samurai gumbo-parser-dev"
checkdepends="gtest-dev"
subpackages="$pkgname-static $pkgname-dev"
source="https://github.com/litehtml/litehtml/archive/v$pkgver/litehtml-$pkgver.tar.gz
	fix-gtest-check.patch
	"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=Release \
		-DLITEHTML_UTF8=ON \
		-DEXTERNAL_GUMBO=ON \
		-DEXTERNAL_GTEST=ON \
		-DBUILD_TESTING=ON \
		-DBUILD_SHARED_LIBS=ON \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)"
	cmake -B build-static -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=Release \
		-DLITEHTML_UTF8=ON \
		-DEXTERNAL_GUMBO=ON \
		-DBUILD_TESTING=OFF
	cmake --build build
	cmake --build build-static
}

check() {
	ctest --output-on-failure --test-dir build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	DESTDIR="$pkgdir" cmake --install build-static
}

sha512sums="
e2df205258c4e6f48cc0d8f900fb62c2da1b18c9ca007f1e222e51a59a632eb122eb2dc6136de6641ed96b3c6c823f7f90d098f2f40f9966b0cb831b180776a4  litehtml-0.8.tar.gz
dd4d42b85a90ecb76e7d95d450e99ffce120a0032fd73196fc06835105bae8f3b3b294743e29d4f177ec363e99ebf1ae7e265e39d656ce9180244d2aafe45e3c  fix-gtest-check.patch
"
